#include <iostream>
#include <vector>
using namespace std;

class App {
	int cnt = 1, start = 1, end = 1;
	long diameter = 0;
	vector<int> head, next, to, weight;
	vector<long> dist;
	vector<int> last;
	vector<bool> diapath;

	void addedge(int u, int v, int w)
	{
		next[cnt] = head[u];
		to[cnt] = v;
		weight[cnt] = w;
		head[u] = cnt++;
	}

	void dfs(int u, int p, long w)
	{
		last[u] = p;
		dist[u] = w;
		for (int e = head[u], v = to[e]; e; e = next[e], v = to[e]) {
			if (v != p) {
				dfs(v, u, w + weight[e]);
			}
		}
	}

	void get_diameter(int n)
	{
		dfs(1, 0, 0);
		for (int i = 2; i <= n; i++) {
			if (dist[start] < dist[i]) {
				start = i;
			}
		}
		dfs(start, 0, 0);
		for (int i = 2; i <= n; i++) {
			if (dist[end] < dist[i]) {
				end = i;
			}
		}
		diameter = dist[end];
	}

	long max_dist(int u, int p)
	{
		long maxdist = 0;
		for (int e = head[u], v = to[e]; e; e = next[e], v = to[e]) {
			if (!diapath[v] && v != p) {
				maxdist = max(maxdist, weight[e] + max_dist(v, u));
			}
		}
		return maxdist;
	}

	int get_compath(int n)
	{
		long maxdist = 0, l = 0, r = 0;
		diapath[end] = diapath[start] = true;
		for (int u = last[end]; u; u = last[u]) {
			diapath[u] = true;
		}

		for (int u = last[end]; u; u = last[u]) {
			maxdist = max_dist(u, 0);
			if (maxdist == diameter - dist[u]) {
				r = u;
			}
			if (maxdist == dist[u] && l == 0) {
				l = u;
			}
		}

		if (l == r) {
			return 1;
		}

		int m = 1;
		while (last[r] != l) {
			m++;
			r = last[r];
		}

		return m;
	}

    public:
	App(int n) : head(n + 1, 0), next(n << 1, 0), to(n << 1, 0), weight(n << 1, 0), dist(n + 1, 0), last(n + 1, 0), diapath(n + 1, false)
	{
		for (int i = 1, u, v, w; i <= n - 1; i++) {
			cin >> u >> v >> w;
			addedge(u, v, w);
			addedge(v, u, w);
		}
		get_diameter(n);
		cout << diameter << endl;
		cout << get_compath(n) << endl;
	}
};

int main()
{
	int n = 0;
	cin >> n;
	App app(n);
	return 0;
}